package com.wan.net.rpc.invoker.client;

import com.wan.net.config.HostAndPort;
import com.wan.net.core.client.AbstractClient;
import com.wan.net.core.client.ClientType;
import com.wan.net.core.tcp.TcpCodec;
import com.wan.net.rpc.util.RpcConstants;
import io.netty.channel.ChannelPipeline;

/**
 * @author wwh
 * @date 2022/6/21 20:42
 */
public class RpcClient extends AbstractClient {

    public RpcClient(HostAndPort host) {
        super(host, RpcConstants.IDLE_TIMEOUT + 180);
    }

    @Override
    protected void channelChannelInitializer(ChannelPipeline pipeline) {
        pipeline.addLast(new TcpCodec());
    }

    @Override
    public ClientType getClientType() {
        return ClientType.RPC;
    }

    @Override
    protected void onInactive() {
        logger.info("rpc客户端->[{}],准备重连......",getTargetRemote());
        super.open();
    }
}
